You need to be able to use both views. Sometimes when you are working on a problem you need to switch between these two views. You might write the code using the static viewpoint, then test and debug the code using the dynamic viewpoint.
Let us practice this. Here is the math-like definition of Triangle
:
And here is another version of the Java method Triangle()
:
int Triangle( int N ) { return N + Triangle( N-1 ); }
Say that you try to run this program..... but it never prints out a result.